<template>
  <DataList 
  :cate="cate" 
  :cols="cols" 
  :name="name"
  :excelHeader="excelHeader"
  skipExcelNumber="2"
  />
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import linq from "linq"
import { addXshj, deleteXshj, updateXshj, getXshj,bulkAddXshj} from "@/api/社会评价.js";
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A9-6-1学生获奖情况表",
      name:"9.6.1 学生获奖情况",
      excelHeader:{B3:"项目名称(全称)",C3:"项目类别",D3:"级别",E3:"获奖日期（年月）",F3:"学生名单",G3:"指导教师名单"},
      cols: [
        { prop: "JSXMMC", label: "项目名称 (全称) " },
        { prop: "XZ_XSHJXMLB", label: "项目类别" },
        { prop: "XZ_XSHJXMJB", label: "级别"},
        { prop: "JSRQ", label: "获奖日期(年月)"},
        { prop: "XSMD", label: "学生名单"},
        { prop: "ZDJSH", label: "指导教师名单"}
      ]
    };
  },
  methods: {
    getSummaries(list){
      const sums = []
         this.cols.forEach((column, index) => {
            sums[index]=""
        })
        sums[0]="合计";
        sums[6]= "项目数:"+linq.from(list).count("$.JSXMMC")
        sums[7]= "类别数:"+linq.from(list).distinct("$.XZ_XSHJXMLB").count()
        sums[12]= "通过:"+linq.from(list).where("$.审核状态=='通过'").count()
        sums[12] += ",待审核:"+linq.from(list).where("$.审核状态=='待审核'").count()
        sums[12]+= ",不通过:"+linq.from(list).where("$.审核状态=='不通过'").count()
        return sums;
    },
    check(array,list) {
     return new Promise(async (resolve,reject)=>{
       resolve();
     })
 },
    async fetchData() {
      var user = getUser();
      var datas = await getXshj(user.XXID,user.CJPC);
      return datas;
    },
    onadd(model) {
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
         
        console.log(JSON.stringify(temp));
        var model = await addXshj(temp);
        resolve(model);
      })
    },
    async bulkAdd(array){
      await bulkAddXshj({Xsjy:array});
    },
    onupdate(model) {
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
          console.log(JSON.stringify(temp));
          var model = await updateXshj(temp);
          resolve(model);
      })
    },
    ondelete(model) {
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
      
      await deleteXshj(temp);
      resolve();
      })
    }
  }
};
</script>
<style>
</style>